package com.lyfx.ly.controller;

import java.util.Arrays;
import java.util.Map;

import com.lyfx.ly.vo.BaseValuesVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.lyfx.ly.entity.ClassCourseAttrValuesEntity;
import com.lyfx.ly.service.ClassCourseAttrValuesService;
import com.lyfx.common.utils.PageUtils;
import com.lyfx.common.utils.R;



/**
 * 课程属性值表
 *
 * @author lsy
 * @email lsy@gmail.com
 * @date 2020-07-11 18:17:24
 */
@RestController
@RequestMapping("ly/classcourseattrvalues")
public class ClassCourseAttrValuesController {
    @Autowired
    private ClassCourseAttrValuesService classCourseAttrValuesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("ly:classcourseattrvalues:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = classCourseAttrValuesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
   // @RequiresPermissions("ly:classcourseattrvalues:info")
    public R info(@PathVariable("id") Long id){
		ClassCourseAttrValuesEntity classCourseAttrValues = classCourseAttrValuesService.getById(id);

        return R.ok().put("classCourseAttrValues", classCourseAttrValues);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // @RequiresPermissions("ly:classcourseattrvalues:save")
    public R save(@RequestBody ClassCourseAttrValuesEntity classCourseAttrValues){
		classCourseAttrValuesService.save(classCourseAttrValues);

        return R.ok();
    }

    /**
     * 保存信息
     * save/baseAttrsValues
     */
    @PostMapping("/save/baseAttrsValues")
    public R saveBaseAttrsValues(@RequestBody BaseValuesVo baseValuesVo){
        //校验
        classCourseAttrValuesService.saveAttrsValues(baseValuesVo);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("ly:classcourseattrvalues:update")
    public R update(@RequestBody ClassCourseAttrValuesEntity classCourseAttrValues){
		classCourseAttrValuesService.updateById(classCourseAttrValues);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("ly:classcourseattrvalues:delete")
    public R delete(@RequestBody Long[] ids){
		classCourseAttrValuesService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
